package com.gxa.modules.communityManagement.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxa.common.utils.PageUtils;
import com.gxa.common.utils.Query;


import com.gxa.modules.communityManagement.entity.HousingManagement;
import com.gxa.modules.communityManagement.mapper.HousingManagementMapper;
import com.gxa.modules.communityManagement.service.HousingManagementService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class HousingManagementServiceImpl extends ServiceImpl<HousingManagementMapper, HousingManagement> implements HousingManagementService {

    @Override
    public PageUtils queryByPage(Map<String, Object> params) {
        String houseUse = (String)params.get("houseUse");
        String buildingName = (String)params.get("buildingName");
        String communityId = (String)params.get("communityId");
        String unitName = (String)params.get("unitName");


        IPage<HousingManagement> page = this.page(new Query<HousingManagement>().getPage(params),
                new QueryWrapper<HousingManagement>().like(StringUtils.isNotEmpty(houseUse),"house_use",houseUse)
                        .eq(StringUtils.isNotEmpty(buildingName),"building_name",buildingName)
                        .eq(StringUtils.isNotEmpty(communityId),"community_id",communityId)
                        .eq(StringUtils.isNotEmpty(unitName),"unit_name",unitName)
        );
        return new PageUtils(page);
    }



}
